package com.whales.lms.rms.web.service;

import java.util.List;

import org.springframework.stereotype.Service;

import anyframe.common.util.StringUtil;

import com.whales.lms.rms.web.model.PcItemVO;
import com.whales.shared.model.CommonVO;
import com.whales.shared.service.GenericService;

@Service
public class PcItemService extends GenericService<PcItemVO, PcItemVO> {
	
	public void update(List<PcItemVO> vo) throws Exception {
		if(vo != null && vo.size() > 0){
			commonDao.create("pcitem.createPcItem", vo);
		}
	}	
	
	public List<PcItemVO> findPcItemByType(PcItemVO vo) throws Exception{
		return super.getList("pcitem.findPcItemByType", vo);
	}
	
	public List<PcItemVO> findProjector() throws Exception{
		return super.getList("pcitem.findProjector", null);
	}
	
	public String findProjectorByPcIp(String ip) throws Exception{
		PcItemVO paramVO = new PcItemVO();
		paramVO.setIp(ip);
		PcItemVO pcItemVO = super.findInfo("pcitem.findProjectorByIp", paramVO);
		if(pcItemVO != null && StringUtil.isNotEmpty(pcItemVO.getIp())){
			return pcItemVO.getIp();
		}else{
			return null;
		}
			
	}
	
	@Override
	public int delete(PcItemVO vo) throws Exception {
		return super.delete("pcitem.deletePcItemByParentId", vo);
	}
	
	public int deleteByHwSwId(CommonVO vo) throws Exception{
		return commonDao.delete("pcitem.deleteByHwSwId", vo);
	}
	
	public int updateProjectorLifeTime(PcItemVO vo) throws Exception{
		return super.update("", vo);
	}
}
